﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WebApplication1.Domain.Entity;

namespace WebApplication1.Domain
{
    public class DbinitialazeHelper
    {
        public static void Initialaze()
        {
            using (var db = new Admin3000DbContext())
            {
                var ISexist = db.Database.EnsureCreated();
                if (!ISexist)
                {
                    var b = new Brands
                    {
                        BrandName = "格力",
                        Description = "世界500强！"
                    };

                    db.Brands.Add(b);
                    db.SaveChanges();

                    db.Proudcts.AddRange(new Proudcts[] {
                    new Proudcts
                    {
                        ProductName = "格力xxx",
                        ShortDesc = "xxx 系列",
                        FullDesc = "格力核心科技",
                        BrandId = b.Id
                    }


                 });
                    db.SaveChanges();
                }

            }
        }
    }
}
